﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Security.Cryptography;
using System.Net;
using System.IO;

namespace McMySkin_Installer
{

    public class Unit
    {
        public static string GetMD5(string str)
        {

            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            string s = BitConverter.ToString(md5.ComputeHash(

                 UTF8Encoding.Default.GetBytes(str)));

            s = s.Replace("-", "");

            return s;
        }

        public static string ReadURL(string url, string postDataStr, Encoding Encode)
        {
            WebClient client = new WebClient();
            client.Encoding = Encode;
            return client.DownloadString(url);
        }

        public static string ConvertToHex(string str)
        {
            string hex = "";
            foreach (char c in str)
            {
                int tmp = c;
                hex += String.Format("{0:x2}", (uint)System.Convert.ToUInt32(tmp.ToString()));
            }
            return hex;
        }

        public static Stream GetPiutureStream(string url)
        {
            WebClient client = new WebClient();

            return new MemoryStream(client.DownloadData(url));
        }

    }
}
